<template
  ><div>
    <keep-alive>
      <people-rejister-one v-if="peopleRejisterStatus == 1" :datalist-one-page="datalistOnePage" @next-page="handlePage"></people-rejister-one>
      <people-rejister-two v-else :current-ports-id="currentPortsId" @pre-page="handlePage"></people-rejister-two
    ></keep-alive>
  </div>
</template>
<script setup lang="ts">
  import { Ref } from 'vue';
  import peopleRejisterOne from './peopleRejisterOne.vue';
  import peopleRejisterTwo from './peopleRejisterTwo.vue';
  import { selectDir } from '@/api/test/interFace';
  import { useRoute } from 'vue-router';
  const route = useRoute();
  let datalistOnePage = ref([]);
  onMounted(async () => {
    let portsId;
    if (route.query.portsId) {
      // portsId = route.query.portsId;
      portsId = parseInt(route.query.portsId);
      let res = await selectDir({ portsId });
      datalistOnePage.value = res.data.ports;
      console.log('dd', res.data.ports);
    }
    console.log(portsId, 'dadada');

    // 发请求
  });
  // const getInfo = () => {
  //   //你可以在这里面进行赋值操作，也可以想template里面通过route.query.xxx赋值
  //   console.log(route.query.portsId, 'dddddd');
  // };
  // getInfo();
  let peopleRejisterStatus = ref(1);
  // 底部按钮---------------
  // 取消按钮
  let cacelbottombtn: Ref<boolean> = ref(false);
  //   上一步或下一步按钮
  let currentPortsId = ref(0); //记住当前的posrtsId,传个人工注册第二个页面使用
  let handlePage = (data: { num: number; portsId?: number }) => {
    // console.log('出发了我', data.num);
    peopleRejisterStatus.value = data.num;
    // console.log(peopleRejisterStatus.value, '当前是');
    if (data.portsId) {
      currentPortsId.value = data.portsId;
    }
    console.log(data.portsId, '我是 portsId');
  };
</script>
<style lang="less" scoped></style>
